package ch06.sz6;



import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LoggingAspect {
    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingAspect.class);
    // 前置增强
    @Before("execution(* com.*.service.*.*(..))")
    public void beforeMethodExecution(JoinPoint joinPoint) {
        LOGGER.info("前置增强：正在执行方法 " + joinPoint.getSignature().getName());
    }
    // 后置增强
    @AfterReturning(pointcut = "execution(* com.*.service.*.*(..))", returning = "result")
    public void afterMethodExecution(JoinPoint joinPoint, Object result) {
        LOGGER.info("后置增强：方法 " + joinPoint.getSignature().getName() + " 执行完成，返回结果: " + result);
    }
}
